package study.io;

import lombok.SneakyThrows;

import java.io.*;

public class FunctionalTest {
    public static String processFile() throws IOException {
        try (BufferedReader br = new BufferedReader(new FileReader("D:\\data.txt"))) {
            return br.readLine();
        }
    }

    public static String processFile(DataInputStream inputStream, BufferedReaderProcessor processor) throws IOException {
        return processor.process(inputStream);
//        try (BufferedReader br = new BufferedReader(new FileReader("D:\\data.txt"))) {
//        }
    }

    @SneakyThrows
    public void test() {
        System.out.println(processFile());
        InputStream fileIn = new FileInputStream("D:\\data.txt");
        FileReader reader = new FileReader("D:\\data.txt");

        try (DataInputStream out = new DataInputStream(fileIn)) {
            System.out.println(processFile(out, DataInputStream::readLine));
        }
    }
}

